/**
 *
 * @file
 *		Heap.h
 *
 * @brief
 *		The abstract class to be implemented by students of 876 group
 *
 * @author
 *		anyav
 */

#ifndef __HEAP_INTERFACE_H__
#define __HEAP_INTERFACE_H__


/**
 * basic interface
 */
class heap876
{
	public:
		enum alloc_flags
		{
			alloc_simple = 0,

			/* monitor allocations in accordance to tag. free_all functionality became available */
			alloc_tagged = 1 << 0,

			/* poison memory to prevent use after free and uninitialized access */
			alloc_debug  = 1 << 1,

			/* the best memory usage (in opposite to the best performance by default) */
			alloc_optimize_mem = 1 << 2
		};

	protected:
		// maximum size available for distribution
		size_t total_limit;

		// flags of allocator
		alloc_flags flag;

		// name of implementation for test purposes
		char*		name;

	public:
		heap876( size_t total_limit, alloc_flags flag, char* name ):
		  total_limit(total_limit), flag(flag), name(name) {};
		virtual ~heap876() {};
		virtual void*	alloc( size_t sz, unsigned int tag = 0 ) = 0;
		virtual void	free( void* ptr ) = 0;
		virtual void	free_all( unsigned int tag ) = 0;

	public:
		size_t get_volume() const { return total_limit; };
		char*  get_name() const { return name; };
		virtual size_t get_occupancy() const = 0;

	private:
		heap876( const heap876& ref ){};
};

#endif
